#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int n = nums.size();
        int dest = -1, cur = 0;
        for (int i = 0; i < n; i++)
        {
            if (nums[cur] == 0) cur++;
            else
            {
                swap(nums[++dest], nums[cur++]);
            }
        }
    }
};

int main()
{
    Solution s;
    vector<int> nums = { 0,1,0,3,12 };
    s.moveZeroes(nums);
    for (auto num : nums)
    {
        cout << num<<" ";
    }
    return 0;
}